#ifndef _MARIO_H_
#define _MARIO_H_

#include "Sprite.h"
#include "Object.h"
#include "MarioGame.h"

#include <list>
using namespace std;

#define MARIO_VX	0.2
#define MARIO_VY	2.0
#define GRAVITY		0.01
#define ACCEL_X		0.001
#define BOTTOM		0
#define MARIO_VX_MAX 0.25

class MarioGame;

/**--------------------------------------------------------
*Program/Project : GameMario
*Written by : 
*Email :
*Created date : 7/10/2012
*Modified by :
*Modified date :
*Version : 1.0
*Description : Lop khoi tao Mario
--------------------------------------------------------**/
class Mario: public Object
{
private:

	Sprite* p_spriteSmall;		//Sprite mario lon
	Sprite* p_spriteBig;		//Sprite mario lon
	Sprite* p_spriteBullet;		//Sprite mario co bullet
	Sprite* p_spriteLight;		//Sprite tao nhap nhay

	//0: Left | 1: Right
	bool is_turn_left;			//kiem tra huong
	bool is_jump;				//kiem tra nhay
	//bool is_ai;				//kiem tra co AI k?
	bool isSmall;				//kiem tra mario con nho hay lon?
	bool isShoot;				//kiem tra mario duoc ban bullet hay chua
	bool isHasStar;				//kiem tra mario co an sao hay chua?
	bool isMoveDown;			//Kiem tra mario co the chuoi cong
	bool isGravity;				//Xet trong luc khi va cham
	bool isDieFall;				//Chet do roi xuong ho

	 
	float _xOld;		//toa do x cu
	float _yOld;		//toa do y cu


	float timeBullet;				//khoang thoi gian sau 1 lan ban bullet
	float timeTransferState;		//khoang thoi gian chuyen frame
	int countFrame;					//so frame chuyen
	float timeProtect;				//thoi gian bao ve sau khi chet



	LPDIRECT3DDEVICE9 d3ddv;
	LPDIRECT3DSURFACE9 backBuffer;
	LPD3DXSPRITE spriteHandler;


	
	/*
	 *	Dan cua mario
	 */
	Object* bullet;
	Object* bullet2;

public:
	/*
	 *	Set/Get Properties
	 */
	D3DXVECTOR2 getPosition();
	bool getIsSmall() {return isSmall;}
	void setIsSmall(bool _isSmall) {isSmall = _isSmall;}
	MarioGame *game_Mario;


	/*
	 *	Constructor/Destructor
	 */
	Mario(LPDIRECT3DDEVICE9 d3ddv,  LPDIRECT3DSURFACE9 backBuffer, LPD3DXSPRITE spriteHandler, float x, float y, MarioGame* Game_Mario, int Obj_state, int Direction);
	~Mario(void);

	
	/*
	 *	Method
	 */
	//void update(int time);
	void update(list<Object*>* obj_list, DxInput* input, float TPF);
	void move(list<Object*>* obj_list, float time);
	void collisionOnTop(Object* obj,list<Object*>* obj_list, float TPF);
	void updateNormal(list<Object*>* staObjs, list<Object*>* dynObjs, DxInput* input, float time);

	void render(int cameraX, int cameraY);

	

	//ham dieu khien input
	void processInput(DxInput *p_input);
	void turnLeft();
	void turnRight();
	void jump();
	void reset();

	void changeState(int state);
};

#endif
